﻿<script type="text/javascript">

    var TimingLog = {};
    TimingLog.DelUrl = "";
    TimingLog.EditUrl = "";
    TimingLog.DeleteFormatter = function (value, rec, index) {
        if (rec.StateID == 1)
            return "";
        return "<a  class='btn-del' href='" + TimingLog.DelUrl + "?LogID=" + rec.UID + "' onclick='TimingLog.Delete(this); return false;' >删除</a>";
    }

    TimingLog.StateFormatter = function (value, rec, index) {
        return value == 1 ? "成功" : "失败";
    }

    TimingLog.EditFormatter = function (value, rec, index) {
        return "<a  class='btn-edit' href='" + TimingLog.EditUrl + "?LogID=" + rec.UID + "' onclick='TimingLog.Edit(this); return false;' >修改</a>";
    }

    TimingLog.Delete = function (e) {
        if (!confirm("确认要删除吗？"))
            return;
        $.post($(e).attr("href"), function (data) {
            if (data.IsOK) {
                $(".tabs-panels .panel:visible").find('#tbLogList').datagrid('reload');
            }
            else
                alert(data.Description);
        });
    }

    TimingLog.ClearLog = function (e) {
        if (!confirm("确认要清除日志吗？"))
            return;
        $.post($(e).attr("href"), function (data) {
            if (data.IsOK) {
                $(".tabs-panels .panel:visible").find('#tbLogList').datagrid('reload');
            }
            else
                alert(data.Description);
        });
    }


    TimingLog.Edit = function (e) {
        $.createWin({ url: e.href, width: 600, height: 550, title: '修改定时服务流程' });
        return false;
    }

    $(document).ready(function () {
        $(".tabs-panels .panel:visible").find('#tbLogList').datagrid({ pagination: true });
    });

</script>
@Html.Hidden("delLogUrl", Url.Action("DeleteLog", new { id = ViewBag.TimingServiceID }))
@Html.Hidden("editLogUrl", Url.Action("EditLog", new { id = ViewBag.TimingServiceID }))
<div class="tt-attach">
    <ul class="op">
        <li>
            @Html.ActionLink("清除日志", "ClearLog", new { id = ViewBag.TimingServiceID }, new { onclick = "TimingLog.ClearLog(this) ; return false;", @class = "btn btn-insertarticle" })
        </li>
    </ul>
</div>
<div style="padding: 5px 10px;">
    <table id="tbLogList" style="height: auto" striped="true" fitColumns="true" title="" iconcls="icon-edit"
    singleselect="true" idfield="UID" url="@Url.Action("LogListData", new { id = ViewBag.TimingServiceID })">
        <thead>
            <tr>
                <th field="StartDateTime" formatter="Common.DateTimeFormatter" width="150" align="center">
                    开始时间
                </th>
                <th field="LapseTime" width="100">
                    流逝时间(毫秒)
                </th>
                <th field="ResultCodeID" formatter="TimingLog.StateFormatter" width="100">
                    运行结果
                </th>
                <th field="Description" width="500">
                    描述
                </th>
            </tr>
        </thead>
    </table>
</div>
